<?php

namespace app\http\middleware;

class WebAuth
{
    public function handle($request, \Closure $next)
    {
        if(!$request->token){
          return json(['code'=>302,'msg'=>'请登录']);
        }
        list($userId,$rand) = explode("\t",model('common/Staff')->ClientKey($request->token,'DECODE'));
        $userInfo = model('common/Staff')->get_one($userId);
        if(!$userInfo){
            return json(['code'=>302,'msg'=>'请登录']);
        }
        $request->userInfo = $userInfo;
        return $next($request);
    }
}
